﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLDC.Common.Estate;
using System.Data;

namespace ZLDC.Estate.UM
{
    public partial class WorkReport : _PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack){
                int id = _Request.GetInt("id", 0);
                DataSet ds = new DataSet();
                ds = ZLDC.Topo.BLL.Estate.DayReportBLL.SelectDayReportListById(id);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    txtTitle.Text = ds.Tables[0].Rows[0]["title"].ToString();
                    txtContent.Value = ds.Tables[0].Rows[0]["content"].ToString();//内容
                    txtAdvise.Value = ds.Tables[0].Rows[0]["adviseandplan"].ToString();
                    string reportDate = ds.Tables[0].Rows[0]["reportdate"].ToString();
                    rDate.Value = reportDate.Substring(0, 10);
                }
                else
                {
                    rDate.Value = DateTime.Now.ToString("yyyy-MM-dd");//默认取当前日期
                    try
                    {
                        txtTitle.Text = _Utility.GetInfoBySession().m_sDeptName.ToString() + " " + _Utility.GetInfoBySession().m_sUserName.ToString() + " 工作总结[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]";
                    }
                    catch 
                    {
                    
                    }
                }
                }
            
        }

    
       
      
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int id = _Request.GetInt("id", 0);
            string reportDate =rDate.Value.Trim();//报告日期;
            string content = txtContent.Value.Trim();
            string adviseandplan = txtAdvise.Value.Trim();
            string title = txtTitle.Text;
            string outmsg = ZLDC.Topo.BLL.Estate.DayReportBLL.p_dayReport_save(id, reportDate, content, adviseandplan, 0, title);
            if (outmsg == "添加成功" || outmsg=="更新成功")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>window.close();</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('" + outmsg + "')</script>");
            }
        }
    }
}
